package com.kindnesslibrary.base;

import java.io.Serializable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by chenhongxin on 2017/5/17.
 */

public class InitClass implements Serializable {

    private String domain;
    /**
     * 线程池
     */
    private ExecutorService executorService;

    public InitClass(String domain){
        this.domain = domain;
        executorService = Executors.newFixedThreadPool(getAvailableSize());
    }

    public String getDomain() {
        return domain;
    }

    public ExecutorService getExecutorService(){
        return executorService;
    }

    public int getAvailableSize(){
        /**
         * 创建有效的线程池
         */
        int size = Runtime.getRuntime().availableProcessors();
        if (size <= 0) {
            size = 1;
        }
        size *= 2;
        return size;
    }

}
